﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class AdminControl_ImportProReport : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dataTable = new DataTable();
        dataTable.Columns.Add("imageurl");
        dataTable.Columns.Add("proname");
        dataTable.Columns.Add("size");
        dataTable.Columns.Add("color");
        dataTable.Columns.Add("company");
        dataTable.Columns.Add("number");
        dataTable.Columns.Add("price");
        dataTable.Columns.Add("sum");
        dataTable.Columns.Add("importdate");

        ShoppingDataContext spdt = new ShoppingDataContext();
        var proimportdetails =  from p in spdt.PRO_IMPORTs
                                join q in spdt.PRODUCTs
                                on p.ProductID equals q.ProductID
                                join r in spdt.PRODUCT_DEs
                                on p.ProductID equals r.ProductID
                                where p.size == r.Size && p.color == r.Color 
                                select new {r.image, q.ProName, p.size, p.color, 
                                            p.number, p.price, p.company, p.importdate};

        foreach (var proimportdetail in proimportdetails)
        {
            DataRow row = dataTable.NewRow();
            row["imageurl"] = proimportdetail.image;
            row["proname"] = proimportdetail.ProName;
            row["size"] = proimportdetail.size;
            row["color"] = proimportdetail.color;
            row["company"] = proimportdetail.company;
            row["number"] = proimportdetail.number;
            row["price"] = proimportdetail.price;
            row["sum"] = proimportdetail.price * proimportdetail.number;
            row["importdate"] = proimportdetail.importdate;
            dataTable.Rows.Add(row);
        }

        importprodetails.DataSource = dataTable;
        importprodetails.DataBind();
    }
}

